package cn.tedu._02mybatis.mapper;

import cn.tedu._02mybatis.pojo.entity.Comment;
import cn.tedu._02mybatis.pojo.vo.SelectCommentVO1;
import cn.tedu._02mybatis.pojo.vo.SelectCommentVO2;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CommentMapper {
    @Insert("INSERT INTO comment(content,created,weibo_id,user_id) VALUES (#{content},#{created},#{weiboId},#{userId})")
    int insertComment(Comment comment);

    @Delete("DELETE FROM comment WHERE id=#{commentId}")
    int deleteComment(Long commentId);

    @Update("UPDATE comment SET content=#{content},created=#{created},weibo_id=#{weiboId},user_id=#{userId} WHERE id=#{id}")
    int updateById(Comment comment);

    //    @Select("SELECT content,user_id userId,weibo_id weiboId FROM comment WHERE id=#{commentId}")
//    SelectCommentVO1 selectCommentVO1(Long commentId);
    @Select("SELECT"+" content,user_id userId,weibo_id weiboId FROM comment WHERE id=#{commentId}")
    SelectCommentVO1 selectCommentVO1(Long commentId);

    @Select("SELECT content,user_id userId FROM comment WHERE weibo_id=#{weiboId}")
    List<SelectCommentVO2> selectCommentVO2(Long weiboId);

}
